import { Component } from '@angular/core';
import {App} from "ionic-angular";
import { NavController, NavParams } from 'ionic-angular';

import { TakePicturesPage } from '../take-pictures/take-pictures';
import { QuestionSetPage } from '../question-set/question-set';
import { MistakedetailPage } from '../../mistakedetail/mistakedetail';

@Component({
  selector: 'page-course-list',
  templateUrl: 'course-list.html'
})
export class CourseListPage {
  icons: string[];
  items: Array<{title: string, note: string, icon: string}>;
  course:Array<{title: string, icon: string}>;
  username: string;

  constructor(public navCtrl: NavController,
              public navParams: NavParams,
              private app:App) {
    this.icons = ['flask', 'wifi', 'beer', 'football', 'basketball', 'paper-plane',
    'american-football', 'boat', 'bluetooth', 'build'];

    this.items = [];
    this.username = this.navParams.get("username");
    for(let i = 1; i < 11; i++) {
      this.items.push({
        title: 'Item ' + i,
        note: 'This is item #' + i,
        icon: this.icons[Math.floor(Math.random() * this.icons.length)]
      });
    }
    this.course = [];

    this.course.push({title:"语文",icon:this.icons[0]});
    this.course.push({title:"数学",icon:this.icons[1]});
    this.course.push({title:"英语",icon:this.icons[2]});
    this.course.push({title:"物理",icon:this.icons[3]});
    this.course.push({title:"化学",icon:this.icons[4]});
    this.course.push({title:"生物",icon:this.icons[5]});

  }

  itemTapped(event, item) {
    this.navCtrl.push(TakePicturesPage, {
      item: item,
    });
  }

  toQuestionSet(title:string){
    console.log("跳转前："+title);
    this.app.getRootNav().push(QuestionSetPage,{
      subject:title,
      username: this.username,
    });
  }

  toMistakeDetail(){
    this.navCtrl.push(MistakedetailPage,{

   });
  }
}
